﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SystemParamAdd.aspx.cs"
    Inherits="ZLDC.Estate.TM.SystemParamAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>常量新增</title>
    <base target="_self" />
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" action="../Handler/HandlerSystem.ashx?act=systemparam_save" enctype="multipart/form-data"
    method="post">
    <div style="height: 4px;">
    </div>
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr>
            <td width="15%" align="right" bgcolor="#F7F7F7">
                常量类型：<font color="red">*</font>
            </td>
            <td width="70%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                <select id="sType" name="sType" style="width: 100px;" runat="server" onchange="return sType_onchange()">
                </select>
                <input id="iType" name="iType" type="text" style="width:60px;" disabled />
                <font color='red'>可手动输入其它类型</font>
            </td>
        </tr>
        <tr>
            <td width="15%" align="right" bgcolor="#F7F7F7">
                常量数据：<font color="red">*</font>
            </td>
            <td width="70%" bgcolor="#FFFFFF" style="padding-left: 10px;">
                <input id="iItem" name="iItem" type="text" />
            </td>
        </tr>
        <tr>
            <td align="right" bgcolor="#F7F7F7">
                备注：
            </td>
            <td bgcolor="#FFFFFF" style="padding-left: 10px;">
                <textarea id="taRemark" name="taRemark" style="width: 180px; height: 70px"></textarea>
            </td>
        </tr>
    </table>
    <div style="width: 100%; padding-top: 15px; cursor: pointer; text-align: center;">        
        <input id="btnOk" class="button_bak" type="button" value="确定" onclick="submitOK()" />                        
    </div>
    <input id="hID" name="hID" type="hidden" runat="server" />
    </form>

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>    

    <script type="text/javascript">
        $(document).ready(function() {
            var id = LexunJS.GetQueryString("id");

            // 修改
            if (id > 0)
                showDetail(id);
            else
                $("#iType").removeAttr("disabled");
        });

        // 查询详细
        function showDetail(id) {
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerSystem.ashx',
                data: 'act=systemparam_detail&id=' + id,
                timeout: '10000',
                error: function() {
                    alert("查询详情失败！");
                }, success: function(json) {
                    showDetailCallBack(json);
                }
            });
        }
        function showDetailCallBack(response) {            
            var json = eval("(" + response + ")");
            var record = json.record;

            if (record == null || record.length == 0)
                return;

            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                $("#hID").val(record[i].id);
                $("#sType").val(record[i].type);
                $("#iItem").val(record[i].item);
                $("#taRemark").val(record[i].mark3);
            }            
        }

        // 提交前验证
        function submitOK() {
            var sValue = LexunJS.GetSelectValue("sType");
            if (sValue == "手填" || sValue == "") {
                var type = document.getElementById("iType").value;
                if (type == "") {
                    alert("手填的常量类型不能为空！");
                    document.getElementById("iType").focus();
                    return false;
                }
            }            

            var item = document.getElementById("iItem").value;
            if (item == "") {
                alert("常量数据不能为空！");
                document.getElementById("iItem").focus();
                return false;
            }

            document.forms[0].submit();
            window.close();
        }

        // 选择常量类型
        function sType_onchange() {
            var typeText = LexunJS.GetSelectText("sType");
            if(typeText == "手填")
                $("#iType").removeAttr("disabled"); 
            else
                $("#iType").attr("disabled", "true");
        }

    </script>

</body>
</html>
